<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- <span v-for="(item,index) in list" :key="item">
            <input type="checkbox" name="list" @click="btn(item,index)">
            <label>{{item}}</label>
        </span> -->

        <span v-for="(item,index) in list" :key="item">
            <input type="checkbox" name="list" :value="item" v-model="newlist">
            <label>{{item}}</label>
        </span>
        <ul>
            <!-- <li v-for="(item,index) in newlist" :key="item.id">{{item.name}}</li> -->
            <li v-for="(item,index) in newlist" :key="item">{{item}}</li>
        </ul>
    </div>
    <script src="../vue.js"></script>

    <script>
        const app = new Vue({
            el: '#app',
            data: {
                list: ["科幻", "喜剧", "动漫", "冒险", "科技", "军事", "娱乐", "奇闻"],
                newlist: []

            },

            // methods: {
            //     btn(name, index) {
            //         if (!this.newlist.find(ele => ele.name === name)) {
            //             this.newlist.push({ id: index, name })
            //         } else {
            //             console.log(this.newlist = this.newlist.filter(e => e.name !== name))
            //         }
            //     }
            // }
        })
    </script>
</body>

</html>